<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>读了么！账号登录</title>
    <link rel="stylesheet" type="text/css" href="CSS/Login.css">
    <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.4.1.js"></script>
</head>
<body>
<div class="content">
    <div class="main">
        <div class="SignHeader">
            读了么
        </div>
        <div class="Signslogen">
            登录 读了么 在线购书
        </div>
        <form action="main.html" method="post">
            <div class="mess">
                <div class="account"><input type="text" id="userAccount" placeholder="请输入账号"/></div>
            </div>
            <div class="mess">
                <div class="pwd"><input type="password" id="userPassword" placeholder="请输入密码"/></div>
            </div>
            <div id="btn">
                <input type="button" value="登录" class="login_b" id="login_b"/>
                <span class="help-block u-errormessage" id="errorMsg">&nbsp;</span>
            </div>
            <div class="register">
                <div class="register_a">没有账号?<a href="register.html">去注册</a>
                </div>
            </div>
        </form>
    </div>
</div>
<script>
    $("#login_b").click(function () {
        var username=$("#userAccount").val();
        var password=$("#userPassword").val();

        $.post("/User/LoginServlet", "userAccount="+username+"&userPassword="+password, function (data, status) {
            if(data==1){
                $("#errorMsg").text("用户名密码正确");
            }else if(data==0){
                $("#errorMsg").text("用户名密码不正确");
            }
        });
    });
</script>
</body>
</html>
